from nicegui import ui, app, context
from starlette.routing import Route

from typing import Literal
from 考试系统.数据交互层.界面.common import TemplatePage
from typing import cast
import 考试系统.数据交互层.GLOBA as GLOBA
from niceguiToolkit.layout import inject_layout_tool
# inject_layout_tool()
class BasePage(
    TemplatePage[Literal["header", "right_drawer", "footer", "body"]]

):
    pass

def base_page():
    dark = ui.dark_mode()
    with ui.header(elevated=True).style("background-color:#3874c8;font-size:1.3rem").classes(
        "items-center justify-between"
    ):
        with ui.row() as header:
            ui.label("欢迎来到在线考试系统")
        ui.button(on_click=lambda: right_drawer.toggle(), icon="menu").style("font-size:0.7rem;color:#610a0a").props(
            "flat color=white"
        )

    with ui.right_drawer(fixed=False).style("background-color:#ebf1fa").props(
        "bordered"
    ) as right_drawer:
        with ui.row():
            day = ui.button('切换至\n白天模式',on_click=lambda :{ui.notify('切换至白天模式'),dark.disable()})
            night = ui.button('切换至\n黑夜模式',on_click=lambda :{ui.notify('切换至黑夜模式'),dark.enable()})
        ui.button('个人信息').style("width:100%")
        ui.button('退出',on_click=lambda :ui.open('./')).style("width:100%;font-size:0.8rem")


    with ui.footer().style("background-color: #3874c8") as footer:
        ui.label("FOOTER")

    # 因为这是基础模板，可能会在不同的路由下被执行
    # 希望只要在 非根路由 函数执行，就显示返回根的link
    # if context.get_client().page.path != "/":
    #     ui.link("返回 base", target="/")

###-----------------主体----------------###
    with ui.column().style("flex-direction:column;width:100%") as body:
        pass





    return BasePage(
        header=header,
        right_drawer=right_drawer,
        footer=footer,
        body=body,
    )
base_page()
ui.run()